import { useState } from "react";

export default function useModal() {
	const [isModalOpen, setIsModalOpen] = useState(false);
	const [id, setId] = useState(0);

	const openModal = (newId?: number) => {
		setIsModalOpen(true);
		if (newId) setId(newId);
	};

	const closeModal = () => {
		setIsModalOpen(false);
	};

	return {
		id,
		isModalOpen,
		openModal,
		closeModal
	};
}
